package org.ipb.controller.modul.jabatanstrukturalpegawai;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ipb.model.JabatanStrukturalPegawai;

import util.hibernate.DAO;

import com.opensymphony.xwork2.ActionSupport;

public class ActionJsonMap extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Map<Integer, String> listPejabat = new HashMap<Integer, String>();
	private String jabatanId;

	public Map<Integer, String> getListPejabat() {
		return listPejabat;
	}

	public void setListPejabat(Map<Integer, String> listPejabat) {
		this.listPejabat = listPejabat;
	}

	@SuppressWarnings("unchecked")
	public String execute() {
		DAO<Integer> dao = new DAO<Integer>();
		dao.createQuery("from JabatanStrukturalPegawai as jsp where id in (select max(id) from "
				+ "JabatanStrukturalPegawai group by strukturOrganisasi.id) order by jsp.strukturOrganisasi.levelDariAtas asc");

		List<JabatanStrukturalPegawai> list = (List<JabatanStrukturalPegawai>) dao
				.resultQuery();
		for (JabatanStrukturalPegawai f : list) {
			listPejabat.put(f.getId(), f.getStrukturOrganisasi()
					.getNamaJabatan()
					+ " "
					+ f.getPegawai().getNip()
					+ " "
					+ f.getPegawai().getNama());
		}
		dao.close();
		return SUCCESS;

	}

	public String getJabatanPegawaiId() {
		return jabatanId;
	}

	public void setJabatanPegawaiId(String jabatanId) {
		this.jabatanId = jabatanId;
	}

}
